{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 目标\n",
    "* 显示 健康 Health\n",
    "* 显示 体力 Stamina\n",
    "* 显示 杀敌数量 Killed\n",
    "* 显示 弹药数 Ammo"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 创建控件蓝图"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "内容浏览器-内容-FirstPersonBP-新建文件夹-UI\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_2.png)\n"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 命名为HUD\n",
    "进入UI文件夹-新建-用户界面-控件蓝图，命名为：HUD\n",
    "    * HUD平视显示器(HeadUpDisplay),简称HUD。在蓝图中是指在屏幕上面绘制的二维物体。\n",
    "\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_3.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 设计界面\n",
    "双击打开HUD的设计器，做如下设计\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_4.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 规范命名\n",
    "养成良好的习惯，规范命名！\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_5.png)\n",
    "编译、保存"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 编辑FirstPersonCharactor"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 从内容-FirstPersonBP-BluePrint，打开蓝图：FirstPersonCharactor\n",
    "* 找到事件BeginPlay，添加动作create widget（创建控件）\n",
    "* class选择类HUD\n",
    "* Return Value 连线到 add to viewport\n",
    "* add to viewport 连接到原来的分支路径\n",
    "\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_6.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 预览效果\n",
    "运行关卡，可看到如下效果\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_7.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 添加变量\n",
    "* 浮点：Health 默认值：1 设为公有变量\n",
    "* 浮点：Stamina 默认值： 1 设为公有变量\n",
    "* 整数：Ammo 默认值：30 设为公有变量\n",
    "* 整数：Killed 默认值：0 设为公有变量\n",
    "\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_8.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 界面元素和变量取得联系\n",
    "HUD设计器-选择滚动条HealthProgressBar-找到percent点击绑定-创建绑定\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_9.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "进入：设计器-图标，做如下设计，完成Health的绑定\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_9_1.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "同样方法创建Stamina的绑定!\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_9_2.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "同样方法创建Killed的绑定\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_9_3.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "同样方法创建Ammo的绑定\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_9_4.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 子弹减少\n",
    "* 编辑：FirstPersonCharacter\n",
    "* 找到Spawn projectile\n",
    "\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_10.png)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 更新杀敌数量\n",
    "编辑Cylinder_Blueprint\n",
    "![image.png](https://gitee.com/lhqer/cplusplus_junior_teacher/raw/master/img/UE4/BP/0003_11.png)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
